package io.github.talelin.latticy.repository;

import io.github.talelin.latticy.entity.UserGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface UserGroupRepository extends JpaRepository<UserGroup, Long> {

    UserGroup findFirstByGroupId(Long groupId);

    @Query("select ug.userId from UserGroup ug where ug.groupId in :groupId")
    List<Long> findUserIdByGroupId(List<Long> groupId);

    @Query("select ug.groupId from UserGroup ug where ug.userId = :userId")
    List<Long> findGroupIdByUserId(Long userId);
}
